//
//  QJView.m
//  svqj
//
//  Created by xftt on 14-6-24.
//
//

#import "QJDown.h"
#import "FilesDownManage.h"
#import "DownViewController.h"
#import "UIImageView+AFNetworking.h"

@implementation QJDown
{
    UIView *prgb;
    UIView *prgl;
}
- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
    }
    [self setBackgroundColor:[UIColor colorWithHexString:@"#5A5A5A"]];
    UIView *backImage = [[UIView alloc] initWithFrame:CGRectMake(8, 8, 220, 149)];
    [backImage setBackgroundColor:[UIColor colorWithHexString:@"#343434"]];
    self.imgvQJ = [[UIImageView alloc] initWithFrame:CGRectMake(1, 1, 218, 147)];
    [self.imgvQJ setBackgroundColor:[UIColor colorWithHexString:@"#eeeeee"]];
    [backImage addSubview:self.imgvQJ];
    [self addSubview:backImage];
    _lbTltle = [[UILabel alloc]initWithFrame:CGRectMake(8, 166, 220, 16)];
    [_lbTltle setBackgroundColor:[UIColor clearColor]];
    [_lbTltle setTextAlignment:NSTextAlignmentCenter];
    [_lbTltle setFont:[UIFont systemFontOfSize:15]];
    [_lbTltle setTextColor:[UIColor colorWithHexString:@"#AAAAAA"]];
    [self addSubview:_lbTltle];
    UIView *line = [[UIView alloc]initWithFrame:CGRectMake(8, 192, 220, 1)];
    [line setBackgroundColor:[UIColor colorWithHexString:@"#777777"]];
    [self addSubview:line];
    prgb = [[UIView alloc]initWithFrame:CGRectMake(8, 200, 220, 17)];
    [prgb setBackgroundColor:[UIColor colorWithHexString:@"#3A3A3A"]];
    [prgb setClipsToBounds:YES];
    [self addSubview:prgb];
    prgl = [[UIView alloc]initWithFrame:CGRectMake(1, 1, 0, 15)];
    [prgl setBackgroundColor:[UIColor colorWithHexString:@"#888888"]];
    [prgb addSubview:prgl];
    _lbLoad = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 220, 17)];
    [_lbLoad setBackgroundColor:[UIColor clearColor]];
    [_lbLoad setTextColor:[UIColor whiteColor]];
    [_lbLoad setFont:[UIFont systemFontOfSize:12]];
    [_lbLoad setTextAlignment:NSTextAlignmentCenter];
    [prgb addSubview:_lbLoad];
    _btnStop = [UIButton buttonWithType:UIButtonTypeCustom];
    [_btnStop setFrame:CGRectMake(8, 224, 90, 38)];
    [_btnStop setTitle:@"暂停" forState:UIControlStateNormal];
    [_btnStop.titleLabel setFont:[UIFont systemFontOfSize:14]];
    [_btnStop setTitleColor:[UIColor colorWithHexString:@"#AAAAAA"] forState:UIControlStateNormal];
    [_btnStop setBackgroundColor:[UIColor colorWithHexString:@"#444444"]];
    [self addSubview:_btnStop];
    _btnEsc = [UIButton buttonWithType:UIButtonTypeCustom];
    [_btnEsc setFrame:CGRectMake(138, 224, 90, 38)];
    [_btnEsc setTitle:@"删除" forState:UIControlStateNormal];
    [_btnEsc.titleLabel setFont:[UIFont systemFontOfSize:14]];
    [_btnEsc setTitleColor:[UIColor colorWithHexString:@"#AAAAAA"] forState:UIControlStateNormal];
    [_btnEsc setBackgroundColor:[UIColor colorWithHexString:@"#444444"]];
    [self addSubview:_btnEsc];
    return self;
}

- (void)setProgressLoad:(CGFloat)max withNow:(CGFloat)now
{
    if (max!=0) {
        CGFloat w = (218/max)*now;
        [prgl setFrameWidth:w];
    }
}

- (void)setQuanjing:(QuanJing *)quanjing
{
    _quanjing = quanjing;
    [self.imgvQJ setImageWithURL:[NSURL URLWithString:quanjing.thumbnail] placeholderImage:[UIImage imageNamed:@"Load"]];
    [_lbTltle setText:quanjing.title];
}


@end
